home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 152 / rscfix.doc < prev    next >
Encoding:
Text File  |  1987-06-21  |  3.9 KB  |  122 lines

  1. RSCFIX.C -- A resource fixer for code-resident resources.
  2.  
  3. RSCFIX.C  contains  a set of routines to prepare  a  code-resident 
  4. resource  for use.   It was derived from STCREATE.C,  found in the 
  5. RSCREATE  folder  on  the Resource Disk supplied  with  the  Atari 
  6. Developer's Kit.
  7.  
  8. The  routines are driven by a main routine,  rsc_fix(),  which you 
  9. call  during your program initialization to prepare the  resource.  
  10. The  routines perform 2 distinct functions on the  resource.   The 
  11. first is to change all the offsets,  generated by RSC,  to address 
  12. pointers.   The  second  function  is  to change  all  the  object 
  13. rectangle  coordinates  and  sizes  from  characters  to   pixels, 
  14. according to the current screen resolution.
  15.  
  16. First  get  the download the file RSCFIX.C and put  it  with  your 
  17. header  files. (e.g.  on  the compiler disk with  ALCYON,  in  the 
  18. HEADERS  folder with Megamax,  in the INCLUDE folder with  Micro-C 
  19. Shell and Mark Williams C, etc.)
  20.  
  21. Next,  create  the  C source file using RCS or RCS2.   To do this, 
  22. run  the RCS program,  Open your resource file,  select the Output 
  23. option  from  the Global menu,  select '.H' and '.C'  ('.RSH'  for 
  24. RCS2),  click on OK, and Close your resource.  Put the these files 
  25. with your source file(s).
  26.  
  27. Then,  modify  your source file to include the resource's C source 
  28. and header files and 'RSCFIX.C'.   Change your call to rsrc_load() 
  29. to  rsc_fix().   Change  your call to rsrc_gaddr to load the  tree 
  30. pointer from the rs_trindex[] array.
  31.  
  32. Limitations:   The  'adj' macro takes care of objects that are not 
  33. character  aligned but seems to have trouble when the root  object 
  34. of a tree is NOT character aligned.   Just make sure all your root 
  35. objects  are  character  aligned  and  you  should  not  have  any 
  36. problems.
  37.  
  38. The following code fragment illustrates the use of rsc_fix().
  39.  
  40. #include <obdefs.h>
  41. #include <gemdefs.h>
  42. .
  43. .
  44. .
  45. #ifndef BYTE                  /* Take care of 'portability' */ 
  46. #define BYTE char             /* macros in the '.RSH' file. */
  47. #define WORD int
  48. #define LONG long
  49. #endif
  50.  
  51. #include "resource.h"         /* The header file from RSC   */
  52. #include "resource.rsh"       /* The C source file from RSC */
  53.  
  54. OBJECT *tree;                 /* Pointer to an object tree  */
  55. .
  56. .
  57. /* global declarations */
  58. .
  59. .
  60. #include <rscfix.c>           /* Code to fixup resource     */
  61.  
  62. void    sort(v,n)
  63. char    *v[];
  64. int     n;
  65.         {
  66.         .
  67.         .
  68.         }
  69. .
  70. .
  71. .
  72. void    do_form( rsc_tree, exit_obj )
  73. int     rsc_tree;
  74. int     exit_obj;
  75.         {
  76.         int     xdial, ydial, wdial, hdial;
  77.         int     x, y, w, h;
  78.         int     object;
  79.  
  80.         tree = (OBJECT *) rs_trindex[ rsc_tree ];
  81.  
  82.         form_center( tree, &xdial, &ydial, &wdial, &hdial );
  83.         x = xdial + wdial/2;
  84.         y = ydial + hdial/2;
  85.         w = gl_wbox;
  86.         h = gl_hbox;
  87.         form_dial( 0, x, y, w, h, xdial, ydial, wdial, hdial );
  88.         form_dial( 1, x, y, w, h, xdial, ydial, wdial, hdial );
  89.  
  90.         objc_draw( tree, ROOT, MAX_DEPTH, xdial, ydial, wdial, hdial );
  91.  
  92.         object = 0;
  93.  
  94.         while( object != exit_obj )
  95.                 {
  96.                 object = form_do( tree, 0 ) & 0x7FFF;
  97.                 handle_object( tree, object );
  98.                 .
  99.                 .
  100.                 .
  101.                 }
  102.  
  103.         form_dial( 2, x, y, w, h, xdial, ydial, wdial, hdial );
  104.         form_dial( 3, x, y, w, h, xdial, ydial, wdial, hdial );
  105.         }
  106.  
  107. main()
  108.         {
  109.         if ( appl_init() >= 0 )
  110.                 {
  111.                 rsc_fix();
  112.                 .
  113.                 .
  114.                 graf_mouse( M_ON, 0x0L );
  115.                 graf_mouse( ARROW, 0x0L );
  116.                 do_form( TREE0, OKBUTTON );
  117.                 .
  118.                 .
  119.                 appl_exit();
  120.                 }
  121.         }
  122. əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə